<?php

include_once("includes/Database.php");

class AgendaModel {

	// Get all Agenda
	public function getAllAgendaList()
	{
		// create an instance of the Database class and call it $db
		$db = new Database();
		//connect database
		$db->connect();
		// do a query to retrieve multiple records
		$query = "SELECT a.imageURL,a.name,a.departureDate,a.leavesFrom,a.journey,a.duration,a.price,a.tourcode
		FROM agendaentry as a";
		// query the database
		$db->select($query);
		// get result
		$results = $db->getResult();	
		// disconect database
		$db->disconnect();
		//return result
		return $results;
	}
	public function getDayActivityByTourCode($id = null)
	{
		// create an instance of the Database class and call it $db
		$db = new Database();
		//connect database
		$db->connect();
		// do a query to retrieve multiple records
		$query = "
		SELECT *
		FROM `dayactivity`
		WHERE `tourCode` = '{$id}'";
		// query the database
		$db->select($query);
		// get result
		$results = $db->getResult();
		// disconect database
		$db->disconnect();
		//return result
		return $results;
	}
	public function getActivityDetailByIdentifyDay($id = null)
	{
		// create an instance of the Database class and call it $db
		$db = new Database();
		//connect database
		$db->connect();
		// do a query to retrieve multiple records
		$query = "
		SELECT *
		FROM `activitydetail`
		WHERE `identifyDay` = '{$id}'";
		// query the database
		$db->select($query);
		// get result
		$results = $db->getResult();
		// disconect database
		$db->disconnect();
		//return result
		return $results;
	}
	//Get Agenda List By id
	public function getAgendaByTourcode($tourcode)
	{
		// create an instance of the Database class and call it $db
		$db = new Database();
		//connect database
		$db->connect();
		// do a query to retrieve one records
		$query = "SELECT a.imageURL,a.name,a.departureDate,a.leavesFrom,a.journey,a.duration,a.price,a.tourcode,b.name,c.name,c.place,c.timeBegin,c.description,c.URL 
					FROM agendaentry as a,DayActivity as b,ActivityDetail as c 
					WHERE tourcode = tourcodeAgenda AND identifyActivityDetail = c.identify AND tourcode = '$tourcode' 
					GROUP BY tourcode,b.name,b.identifyActivityDetail,a.name 
					ORDER BY a.name,b.name,c.timeBegin";
		// query the database
		$db->select($query);
		// get result
		$results = $db->getResult();
		// disconect database
		$db->disconnect();
		//return result
		return $results;
	}
	//Get Agenda List By Tourguide id
/*	public function getAgendaListByTourguiderId($tourguiderId)
	{
		// create an instance of the Database class and call it $db
		$db = new Database();
		//connect database
		$db->connect();
		// do a query to retrieve one records
		$query = "SELECT agendaId,agendaName,agendaDateStart,agendaDateEnd,tourguiderName, agendaDescription FROM agenda INNER JOIN tourguider ON agenda.tourguiderId= tourguider.tourguiderId WHERE agenda.tourguiderId = $tourguiderId";
		// query the database
		$db->select($query);
		// get result
		$results = $db->getResult();
		// disconect database
		$db->disconnect();
		//return result
		return $results;
	}*/
}

?>